//
//  SongsMenuButtonModel.m
//  NewMusic
//
//  Created by chuxinyu123 on 15/11/21.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "SongsMenuButtonModel.h"

@implementation SongsMenuButtonModel
- (void)dealloc
{
    [_childrenArray release];
    [_tagTitle release];
    [_tagID release];
    [super dealloc];
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super init];
    if (self) {
        self.childrenArray = [NSMutableArray array];
        [self setValuesForKeysWithDictionary:dictionary];
    }
    return self;
}

+ (SongsMenuButtonModel *)songsMenuButtonModelWithDictionary:(NSDictionary *)dictionary
{
    SongsMenuButtonModel *songs = [[SongsMenuButtonModel alloc] initWithDictionary:dictionary];
    return songs;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqual:@"children"]) {
        for (NSDictionary *dic in value) {
            SongsMenuDataModel *song = [SongsMenuDataModel songsMenuDataModelWithDictionary:dic];
            [self.childrenArray addObject:song];
        }
    }else if ([key isEqual:@"tag"]) {
        self.tagTitle = value;
    }
}

- (void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqual:@"tagID"]) {
        self.tagID = [NSString stringWithFormat:@"%@", value];
    }else{
        [super setValue:value forKey:key];
    }
}

@end
